<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>array function</title>
    <style>
        .box {
            width: 100px;
            height: 50px;
            background: #f40;
        }
    </style>
</head>
<body>


<script type="text/javascript">

    +function(){     

        var ary = [15,13,52,14,63,59];

        // 遍历数组中每一项
        /* var res = ary.forEach(function (item,index,originArr) {

        });

        console.log(res); // -> undefined  (回调函数不输出任何值，也不改变原来的数组)*/


        var res = ary.map(function (item,index,originArr) {
            return item*10;
        });

        console.log(res); // ->  [150, 130, 520, 140, 630, 590]
        console.log(ary); // -> [15, 13, 52, 14, 63, 59]

    }();


    +function () {

      var getUserInfo = function(who,callback) {
          if(who==="ws"){
              callback();
              console.log("success");
          }
      };  

      getUserInfo("ws",function () {
          alert("ok");
      });

    }()


    +function (){

        var appendDiv = function (callback) {
            for(var i=0;i<50;i++){
                var newDiv = document.createElement("div");
                document.getElementsByTagName("body")[0].append(newDiv);
                if(typeof callback == "function"){
                    callback(newDiv);
                }
            }
        };
        appendDiv(function (node) {
            node.className="box";
            node.onclick = function () {
                alert(1);
            }
        });
    }()

    +function () {

        



    } ();

    

</script>

</body>
</html>